//
//  Message.swift
//  OCDistributor
//
//  Created by Sam Chen on 2019/12/12.
//  Copyright © 2019 Sam Chen. All rights reserved.
//

/// 消息
public struct OCDistributorMessage: Codable {
    public let fromCustomerId: Int
    public let from: String
    public let message: String
    public let dateAdded: String

    private enum CodingKeys: String, CodingKey {
        case fromCustomerId
        case from = "customerName"
        case message = "text"
        case dateAdded
    }
}

public extension OCDistributorMessage {
    /// 团队/会员转化为消息 model
    init(from member: OCDistributorMember) {
        fromCustomerId = member.customerId
        from = member.fullname
        message = ""
        dateAdded = ""
    }
}
